import { PluginFunction, VueConstructor } from 'vue';
import draggable from 'vuedraggable';
import {
  AttributeArea,
  DesignArea,
  MaterialArea,
  MaterialItem,
  PanelDesignContainer,
  PanelItemContainer,
} from './components';
import { PanelConst } from './constants';
import {
  AbsoluteLayout,
  GridLayout,
  LayoutPanel,
  LayoutPanelMaterial,
  LayoutPanelProvider,
  TableLayout,
} from './extension-components';
import { panel } from './panel-global';

export const install: PluginFunction<unknown> = (vue: VueConstructor, _config: unknown) => {
  vue.component('draggable', draggable);
  vue.component('attribute-area', AttributeArea);
  vue.component('design-area', DesignArea);
  vue.component('material-area', MaterialArea);
  vue.component('material-item', MaterialItem);
  vue.component('panel-design-container', PanelDesignContainer);
  vue.component('panel-item-container', PanelItemContainer);
  // 布局组件
  vue.component('layout-panel', LayoutPanel);
  vue.component('layout-panel-material', LayoutPanelMaterial);
  vue.component('absolute-layout', AbsoluteLayout);
  vue.component('grid-layout', GridLayout);
  vue.component('table-layout', TableLayout);
  // 注册适配器
  panel.registerProvider(PanelConst.LAYOUT_PANEL, new LayoutPanelProvider());
};

export default { install };
export { panel };
export * from './components';
